﻿using CatUtilsDll.Utils.Currency.WebUtils;
using RabbitDownload.Helper;
using System.Net;

namespace RabbitDownload.WebSite.Pixiv.Login
{
    internal class LoginStaticValue
    {
        private static string loginIndex = "https://accounts.pixiv.net/login?lang=zh&source=pc&view_type=page&ref=wwwtop_accounts_index";
        private static string loginPostTo = "https://accounts.pixiv.net/api/login?lang=zh";

        public class PixivLoginJson
        {
            public class Success
            {
                /// <summary>
                ///
                /// </summary>
                public string return_to { get; set; }
            }

            public class Body
            {
                /// <summary>
                ///
                /// </summary>
                public Success success { get; set; }
            }

            public class Root
            {
                /// <summary>
                ///
                /// </summary>
                public string error { get; set; }

                /// <summary>
                ///
                /// </summary>
                public string message { get; set; }

                /// <summary>
                ///
                /// </summary>
                public Body body { get; set; }
            }
        }

        public class LoginSucess
        {
            public class Validation_errors
            {
                /// <summary>
                /// 登录已经完成，请刷新页面。
                /// </summary>
                public string etc { get; set; }
            }

            public class Body
            {
                /// <summary>
                ///
                /// </summary>
                public Validation_errors validation_errors { get; set; }
            }

            public class Root
            {
                /// <summary>
                ///
                /// </summary>
                public string error { get; set; }

                /// <summary>
                ///
                /// </summary>
                public string message { get; set; }

                /// <summary>
                ///
                /// </summary>
                public Body body { get; set; }
            }
        }

        public static WebHeaderCollection GetPostHeader()
        {
            WebHeaderCollection webHeaderCollection = WebHelper.PcWebHeader();
            webHeaderCollection.Add("Accept", "application/json");
            webHeaderCollection.Add("Host", "accounts.pixiv.net");
            webHeaderCollection.Add("origin", "https://accounts.pixiv.net");
            webHeaderCollection.Add("Referer", "https://accounts.pixiv.net/login?lang=zh&source=pc&view_type=page&ref=wwwtop_accounts_index");

            return webHeaderCollection;
        }

        /// <summary>
        /// 登录页面的链接
        /// </summary>
        public static string LoginIndex { get => loginIndex; set => loginIndex = value; }

        /// <summary>
        /// 发送post请求登录
        /// </summary>
        public static string LoginPostTo { get => loginPostTo; set => loginPostTo = value; }
    }
}